{extend name="public/base"}

{block name="title"}
摩邦维修店
{/block}

{block name="style"}
{css href="/static/wechat/css/index.css" /}
{css href="/static/wechat/popo/css/store.css" /}
{css href="/static/wechat/popo/css/shop.css" /}
<style>
    .msg_panel{position:fixed;top:0px;left:100%;width:100%;height:100%;background:#fff;overflow:auto;z-index:99;}
    .weui-popup__overlay{opacity:1;}
    .weui-dialog__btn{color:#0bb20c;font-size:0.8rem;}
    .weui-dialog, .weui-toast{box-shadow:0 0 3px 0 #000;}
    .store_message_logo img{height:2rem;}
    #box_order_list .weui-cell:before{z-index:999;}
    .so_btn {
        display: inline-block;
        width: 95%;
        background: #907050;
        text-align: center;
        height: 2rem;
        line-height: 2rem;
        font-size: .8rem;
        color: #fff;
        margin: 1rem auto 0 2.5%;
    }
    .store_message_serve>a:first-child {
        text-align: center;
    }
    .shop_succ .weui-flex__item img {
        display: block;
        width: 100%;
        height: 100%;
    }
    .weui-flex1{
        width: 100%;
    }
    .weui-flex1 .weui-flex__item{
        margin: 1%;
        width: 29.5%;
        height: 5rem;
        display: inline-block;
    }
    .shop_succ .shop_ment_img{
        height: auto;
    }

</style>
{/block}

{block name="body"}
<div class="pageControl store">
    <div class="nav">
        <div class="msui_navTop">
            <a class="msui_navTop-back" href="javascript:;" onclick="history.back();"><i class="micon-back_fff"></i></a>
            <h1 class="msui_navTop-title">店铺信息</h1>
        </div>
    </div>
    <div class="weui-cells store_message">
        <div class="weui-cell weui-cell_access store_message_logo">
            <div class="weui-cell__bd">
                <p class="fs08">店铺logo</p>
            </div>
            <a href="#" class="weui-cell__ft">
                <img id="uploaderInput0_img" src="{$repair.logo|get_img_url}" alt=""/>
            </a>
            <input id="uploaderInput0" class="weui-uploader__input" type="file" accept="image/*"   file-attr="" />
        </div>
        <div class="weui-cell weui-cell_access" id="s_repair_name_but">
            <div class="weui-cell__bd">
                <p class="fs08">店铺名称</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-3333">
                {$repair.repair_name|default=''}
            </a>
        </div>
        <div class="weui-cell weui-cell_access" id="s_address_but">
            <div class="weui-cell__bd">
                <p class="fs08">店铺地址</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-3333">
                {$repair.address|default=''}
            </a>
        </div>
        <div class="weui-cell weui-cell_access" id="s_time_but">
            <div class="weui-cell__bd">
                <p class="fs08">营业时间</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft store_message_time">
                <p class="fs07 cl-3333" data="{$repair.week|default=''}"></p>
                <p class="fs05 cl-9999">{$repair.open_time|default=''}-{$repair.close_time|default=''}</p>
            </a>
        </div>
    </div>
    <div class="weui-cells" id="s_item_but">
        <a href="javascript:;" class="weui-cell">
            <div class="weui-cell__bd">
                <p>经营项目</p>
            </div>
            <p href="javascript:;" class="weui-cell__ft cl-3333">

            </p>
        </a>
        <div class="weui-flex weui-cell store_message_serve">
            {volist name="repair.item" id="v"}
                <a id="myItem{$v.id}" class="weui-flex__item"
                   {notempty name='v.r_id'}style="display:block"{else}style="display:none"{/notempty}
                >{$v.item_name}</a>
            {/volist}
        </div>
    </div>
    <div class="weui-cells" id="s_ketubbah_but">
        <div class="weui-cell weui-cell_access">
            <div class="weui-cell__bd">
                <p class="fs08">保证金保障服务</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-9999 a_cl9">
                {$repair.ketubbah!='0.00'?$repair.ketubbah.'元':'未开通'}
            </a>
        </div>
    </div>
    <div class="weui-cells" id="s_business_license_but">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p class="fs08">营业执照信息</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-9999 store_message_yy">
                <img src="{$repair.business_license|get_img_url}" alt=""/>
            </a>
        </div>
    </div>
    <div class="weui-cells">
        <div class="weui-cell weui-cell_access" id="s_cover_but">
            <div class="weui-cell__bd">
                <p class="fs08">店铺门面</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-9999 store_message_yy a_cl9">
                {if $repair.cover==""} 请上传（选填） {else} 已上传 {/if}
            </a>
        </div>
        <div class="weui-cell weui-cell_access" id="s_environment_img_but">
            <div class="weui-cell__bd">
                <p class="fs08">环境图</p>
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-9999 store_message_yy a_cl9">
                {if $repair.environment_img1==""} 请上传（选填） {else} 已上传 {/if}
            </a>
        </div>
    </div>
</div>




<!--s_repair_name-->
<div id="s_repair_name_box" class="msg_panel">
    <div class="pageControl store">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">店铺名称</h1>
                <a class="msui_navTop-icon cl-f fs08" href="javascript:;">保存</a>
            </div>
        </div>
        <div class="weui-cells store_address">
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__bd">
                    <input name="repair_name" class="weui-input" type="text" placeholder="请输入店铺名称" value="{$repair.repair_name|default=''}" />
                </div>
            </div>
        </div>
        <p class="store_name_txt">4-20个字，可由中英文,数字组成</p>
    </div>
</div>

<!--s_address-->
<div id="s_address_box" class="msg_panel">
    <div class="pageControl store">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">店铺地址</h1>
            </div>
        </div>
        <div class="weui-cells store_address">
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <p>省、市、区</p>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_shengshiqu" type="text" class="weui-input" placeholder="省 市 区" readonly="" data-code="{$repair.area|default=''}" data-codes="{$repair.province|default=''},{$repair.city|default=''},{$repair.area|default=''}">
                    <input name="s_province" type="hidden" value="{$repair.province|default=''}">
                    <input name="s_city" type="hidden" value="{$repair.city|default=''}">
                    <input name="s_area" type="hidden" value="{$repair.area|default=''}">
                </div>
                <div class="weui-cell__ft">

                </div>
            </div>
            <a href="#" class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <p>街道</p>
                </div>
                <div class="weui-cell__bd">
                    <select name="s_street" class="weui-select" data="{$repair.street|default=''}" style="height:1rem;line-height:1rem;padding-left:0px;font-size:0.7rem;">
                        <option value="{$repair.street|default=''}">请选择...</option>
                    </select>
                </div>
                <!--<div class="weui-cell__ft">-->
                <!--<span>请选择</span>-->
                <!--</div>-->
            </a>
        </div>
        <a href="#" class="weui-cell" id="store_detailed_address">
            <div class="weui-cell__hd">
                <p class="fs08">详细地址</p>
            </div>
            <div class="weui-cell__bd">
                <input name="s_address" type="text" class="weui-input" placeholder="请输入详细地址" value="{$repair.address|default=''}">
            </div>
            <div class="weui-cell__ft" id="box_map_open">
                <img src="/static/wechat/images/shop1_03.jpg" alt="" />
                <p>点击选择</p>
            </div>
        </a>
        <input type="hidden" name="s_lat" value="{$repair.lat|default='0'}" />
        <input type="hidden" name="s_lon" value="{$repair.lon|default='0'}" />
        <a href="" class="weui-btn store_cash_btn bg-ffa">保存</a>
    </div>

</div>

<!--s_time-->
<div id="s_time_box" class="msg_panel">
    <div class="pageControl store">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">营业时间</h1>
                <a class="msui_navTop-icon cl-f fs08" href="javascript:;">保存</a>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell">
                <p>营业时间</p>
            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__bd">
                    <p class="fs08">开始时间</p>
                </div>
                <div class="cl-3333">
                    <input type="time" name="open_time" value="{$repair.open_time}" style="font-size:0.8rem;border:none;" />
                </div>
            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__bd">
                    <p class="fs08">结束时间</p>
                </div>
                <div class="cl-3333">
                    <input type="time" name="close_time" value="{$repair.close_time}" style="font-size:0.8rem;border:none;" />
                </div>
            </div>
        </div>
        <div class="weui-cells weui-cells_checkbox">
            <div class="weui-cell">
                <p>营业日</p>
            </div>
            <label for="sWeek0" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek0" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期日</p>
                </div>
            </label>
            <label for="sWeek1" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek1" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期一</p>
                </div>
            </label>
            <label for="sWeek2" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek2" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期二</p>
                </div>
            </label>
            <label for="sWeek3" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek3" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期三</p>
                </div>
            </label>
            <label for="sWeek4" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek4" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期四</p>
                </div>
            </label>
            <label for="sWeek5" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek5" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期五</p>
                </div>
            </label>
            <label for="sWeek6" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sWeek6" type="checkbox" name="checkbox1" class="weui-check"/>
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>星期六</p>
                </div>
            </label>
        </div>
    </div>

</div>

<!--s_item-->
<div id="s_item_box" class="msg_panel">
    <div class="pageControl store">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">经营项目</h1>
                <a class="msui_navTop-icon cl-f fs08" href="javascript:;">保存</a>
            </div>
        </div>
        <div class="weui-cells weui-cells_checkbox">
            {volist name="repair.item" id="v"}
            <label for="sItem{$v.id}" class="weui-cell weui-check__label">
                <div class="weui-cell__hd">
                    <input id="sItem{$v.id}" data_id="{$v.id}" data_r_id="{$v.r_id}" type="checkbox" name="checkbox2" class="weui-check"
                           {notempty name='v.r_id'}checked="checked"{else} {/notempty}
                    />
                    <span class="weui-icon-checked"></span>
                </div>
                <div class="weui-cell__bd">
                    <p>{$v.item_name}</p>
                </div>
            </label>
            {/volist}
        </div>
    </div>

</div>

<!--s_ketubbah-->
<div id="s_ketubbah_box" class="msg_panel">
    <div class="pageControl store">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">保证金保障</h1>
            </div>
        </div>
        <p class="store_cash_price cl-3333 fs12 text-center">{$repair.ketubbah}</p>
        <a href="#" class="store_cash_txt1 cl-3333 fs07 text-center">保证金余额 (元)</a>
        {if $repair.ketubbah!='0.00'}
            <p class="store_cash_txt2 cl-9999 fs06 text-center">您{$repair.ketubbah_time?date('Y-m-d',$repair.ketubbah_time):''}开通保证金保障服务</p>
            <a id="s_ketubbah_refund_but" href="javascript:;" class="weui-btn store_cash_btn bg-ffa">退保证金</a>
            <p class="store_cash_btn cl-9999 fs06 text-center">
                &nbsp;
            </p>
        {else}
            <p class="store_cash_txt2 cl-9999 fs06 text-center">您尚未开通保证金保障服务</p>
            <a id="s_ketubbah_pay_but_no" href="javascript:;" class="weui-btn store_cash_btn bg-ffa" style="background:#999;">缴纳开通</a>
            <a id="s_ketubbah_pay_but" nowMoney="{$repair.money}" payMoney="{$Think.config.system.repair_shop_margin}" href="javascript:;" class="weui-btn store_cash_btn bg-ffa" style="display:none;margin-top:1rem;">缴纳开通</a>
            <p class="store_cash_btn cl-9999 fs06 text-center">
                <label for="s_ketubbah_checkbox"><input id="s_ketubbah_checkbox" type="checkbox"
                 onchange="if( !$('#s_ketubbah_checkbox').is(':checked')){$('#s_ketubbah_pay_but_no').show();$('#s_ketubbah_pay_but').hide();}else{$('#s_ketubbah_pay_but_no').hide();$('#s_ketubbah_pay_but').show();}" />阅读并同意保证金保障服务协议</label>
            </p>
        {/if}
        <div class="store_cash_introduce">
            <p class="store_cash_txt3 fs08">保证金介绍</p>
            <p class="store_cash_txt4 ">什么是保证金</p>
            <p class="cl-9999">保证金属于不可用余额，用于发生订单维权退款时及时赔付给买家,提升客户消费体验。</p>
            <p class="cl-ffa store_cash_txt5"><span>*</span> 保证金不是向摩邦支付，是可退回的。</p>
            <p class="store_cash_txt4 ">开通保证金的好处</p>
            <p class="cl-9999">除享有平台接单权利外,还享有</p>
            <p class="cl-ffa store_cash_txt5"><span>*</span> "保证金保障" 安全表示 * 客户更多信任</p>
            <p class="cl-ffa store_cash_txt5"><span>*</span> 摩邦更多流量支持</p>
        </div>
    </div>
</div>

<!--s_business_license-->
<div id="s_business_license_box" class="msg_panel">
    <div class="pageControl store bg-f7">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">营业执照认证</h1>
            </div>
        </div>
        <div class="weui-cell bg-f7">
            <p>营业执照信息</p>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                注册号
            </div>
            <div class="weui-cell__bd">
                <input name="business_license_num" type="text" class="weui-input" placeholder="请输入营业执照的注册号" value="{$repair.business_license_num}" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                执照名称
            </div>
            <div class="weui-cell__bd">
                <input name="business_license_name" type="text" class="weui-input" placeholder="请输入营业执照名称" value="{$repair.business_license_name}" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-label">
                注册号
            </div>
            <a href="javascript:;" class="weui-cell__ft cl-9999 store_message_yy">
                <img src="{$repair.business_license|get_img_url}" alt=""/>
            </a>
            <input id="uploaderInput1" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
            <input name="business_license" type="hidden" value="{$repair.business_license}" />
        </div>
        <div class="store_top">
            <span class="weui-btn bg-ffa" id="s_yyzz_submit_but_no" style="background:#999;width:90%;margin:2rem auto;">提交审核</span>
            <a href="javascript:;" class="weui-btn bg-ffa" id="s_yyzz_submit_but" style="display:none;">提交审核</a>
        </div>
    </div>
</div>

<!--s_cover-->
<div id="s_cover_box" class="msg_panel">
    <div class="pageControl startShop bg-f8">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">店铺门面</h1>
            </div>
        </div>
        <div class="shop_succ">
            <div class="shop_store_img" >
                <div class="shop_store_img1" >
                    <img src="{$repair.cover|get_img_url}" style="width:auto;max-height:180px;" alt="" />
                    <input id="uploaderInput2" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                    <input type="hidden" value="{$repair.cover|default=''}" name="cover" />
                </div>
            </div>
            <div class="shopStart_txt shopStart_txt_top">
                <p class="cl-3333">请上传清晰的门店招牌图片，招牌要与商家名称一致，不要有水印，LOGO，二维码，地址，电话等。不要上传效果图或PS图等非真实图片</p>
            </div>
            <div class="shop_btn">
                <a href="javascript:;" class="weui-btn">上传照片</a>
            </div>
        </div>
    </div>
</div>

<!--s_environment_img-->
<div id="s_environment_img_box" class="msg_panel">
    <div class="pageControl startShop bg-f8">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">环境图</h1>
            </div>
        </div>
        <div class="shop_succ">
            <div class="shop_ment_img">
                <div class='weui-flex1'>
                    <span id="box_add_img">
                        {notempty name='repair.environment_img1'}
                            <img class="weui-flex__item" src="{$repair.environment_img1|get_img_url}" title="environment_img1" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img2'}
                            <img class="weui-flex__item" src="{$repair.environment_img2|get_img_url}" title="environment_img2" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img3'}
                            <img class="weui-flex__item" src="{$repair.environment_img3|get_img_url}" title="environment_img3" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img4'}
                            <img class="weui-flex__item" src="{$repair.environment_img4|get_img_url}" title="environment_img4" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img5'}
                            <img class="weui-flex__item" src="{$repair.environment_img5|get_img_url}" title="environment_img5" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img6'}
                            <img class="weui-flex__item" src="{$repair.environment_img6|get_img_url}" title="environment_img6" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img7'}
                            <img class="weui-flex__item" src="{$repair.environment_img7|get_img_url}" title="environment_img7" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                        {notempty name='repair.environment_img8'}
                            <img class="weui-flex__item" src="{$repair.environment_img8|get_img_url}" title="environment_img8" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()"  alt="" />
                        {/notempty}
                    </span>
                    <a href="javascript:;" class="weui-flex__item">
                        <img src="/static/wechat/images/jia1_03.png" alt=""/>
                        <input id="add_img_input" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                    </a>
                </div>
            </div>
            <div class="shopStart_txt shopStart_txt_top">
                <p class="cl-3333">上传店铺环境图或店铺外景图，可以提高曝光率以及用户的购买率。图片要求</p>
            </div>
            <div class="shop_btn">
                <a href="javascript:;" class="weui-btn">提交照片</a>
            </div>
        </div>
    </div>

</div>



<!-- loading toast -->
<div id="loadingToast" style="display:none">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>
<div id="iosDialog2" class="js_dialog" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__bd">弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内</div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" onclick="$('#iosDialog2').hide();" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
        </div>
    </div>
</div>

<!--map-->
<div id="box_map" style="display:none;position:fixed;top:0;left:0;z-index:9999;width:100%;height:100%;">
    <div id="container" tabindex="0" style="display:block;position:absolute;top:0;left:0;z-index:9999;width:100%;height:100%;"></div>
    <img id="box_map_close" src="/static/wechat/images/radio.png" style="position:absolute;right:10px;bottom:10px;z-index:9999;width:auto;height:auto;" />
    <img src="http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png" style="display:block;position:absolute;top:50%;left:50%;z-index:9999;width:19px;height:31px;margin:-31px 0 0 -9px;width:auto;height:auto;" />
</div>



{/block}
{block name="javascript"}
<!--<script src="/static/wechat/popo/js/shop.js"></script>-->
<script type="text/javascript" src="/static/wechat/jquery_weui/js/data-picker1.js" ></script>
<script type="text/javascript" src="/static/wechat/jquery_weui/js/city-picker.js" ></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=9a8d0d7e358d9d80f7f61a1989ba35a0"></script>
<script>
//改写原生的对话框
function sAlert(s){
    $('#iosDialog2').show();
    $('#iosDialog2 .weui-dialog__bd').html(s);
}
window.alert = function(s){sAlert(s);}



var s_submit_but_check = window.setInterval(function(){

    //营业执照
    if(
        $("#s_business_license_box input[name='business_license_name']").val().length<5
        || $("#s_business_license_box input[name='business_license_num']").val().length<9
        || $("#s_business_license_box input[name='business_license']").val().length<15
    ){
        $('#s_yyzz_submit_but_no').show();
        $('#s_yyzz_submit_but').hide();
    }else{
        $('#s_yyzz_submit_but_no').hide();
        $('#s_yyzz_submit_but').show();
    }

},1000);

//长按删除图片
function del_uploads_img(o){
    window.t_img = o;
    window.t_uploads = setTimeout(function(){
        if(window.confirm("确定删除?")){
            var formData = new Object();
            formData.img = '/uploads/'+window.t_img.src.split('/uploads/')[1];
            $.ajax({
                url: '{:url("Base/del_upload_img")}' ,
                type: 'POST',
                data: formData,
                dataType:"json",
                success: function (d) {
                    if(d.code==200){
                        window.t_img.parentNode.removeChild(window.t_img);
                        if(window.t_img.title){
                            repair_info_change([window.t_img],[""]);
                        }
                    }else{
                        var code = d.code;
                        $.alert(error_code[code]);
                    }
                },
                error: function (d) {
                    alert('网络异常');
                }
            });

        }
    },666);
}
//取消长按删除图片
function del_uploads_img_clear(){
    window.clearTimeout(window.t_uploads);
}
//添加图片
$("#s_environment_img_box #add_img_input").change(function(){
    if($("#s_environment_img_box img.weui-flex__item").length>4){
        alert('只能添加5张图片');
    }else{
        $('#loadingToast').show();
        window.setTimeout(function(){
            var formData = new FormData();
            formData.append("type","environment");
            formData.append("img",$("#s_environment_img_box #add_img_input")[0].files[0]);
            $.ajax({
                url: '{:url("Base/get_upload_img")}' ,
                type: 'POST',
                data: formData,
                async: false,
                cache: true,
                contentType: false,
                processData: false,
                dataType:"json",
                error: function (d) {
                    $('#loadingToast').fadeOut();
                    alert('网络异常');
                },
                success: function (d) {
                    $('#loadingToast').fadeOut();
                    if(!d.code){
                        alert(d.msg);
                    }else{
                        $("#s_environment_img_box #box_add_img").prepend('<img class="weui-flex__item new_add" src="'+SCOPE.image_host_url+d.data.path+'" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />');
                    }
                }
            });
        },666);

    }
});

function repair_info_change(fArr,vArr){
    if(fArr.length!=vArr.length){
        alert('字段和值不对称');return false;
    }
    for(i=0;i<fArr;i++){
        fArr[i] = fArr[i].replace("[|]/g","");
        vArr[i] = vArr[i].replace("[|]/g","");
    }
    $('#loadingToast').fadeIn();
    $.ajax({
        url: '{:url("repair_info_change")}' ,
        type: 'POST',
        data: {
            fields : fArr.join("[|]"),
            values : vArr.join("[|]")
        },
        dataType:"json",
        error: function (d) {
            $('#loadingToast').fadeOut();
            alert('网络异常');
        },
        success: function (d) {
            $('#loadingToast').fadeOut();
            if(!d.code){
                alert(d.msg);
            }else{
                //OK
            }
        }
    });
}

//处理定位信息
function onComplete(data){
    //point	Point	坐标点。
    //accuracy	Number	定位精确程度，单位为米。

    if(data.info=="SUCCESS"){
        $('input[name="s_lat"]').val(data.position.lat);
        $('input[name="s_lon"]').val(data.position.lng);
        map_get_address();
    }
}

//处理定位出错信息
function onError(e){
    return false;
}

function map_get_address(){
    $('#loadingToast').fadeIn();
    $.ajax({
        type:"get",
        cache:false,
        dataType:"json",
        url:"{:url('Base/map_get_address')}?lat="+$('input[name="s_lat"]').val()+"&lng="+$('input[name="s_lon"]').val(),
        error:function(s){
            $('#loadingToast').fadeOut();
        },
        success:function(d){
            $('#loadingToast').fadeOut();
            if(d.status==1){
                var tmpAddress = d.regeocode.formatted_address.split(d.regeocode.addressComponent.township)[1]
                $('input[name="s_address"]').val(tmpAddress);
            }else{
                alert(d.info);
            }
        }
    });
}

function getWeekStr(s){
    var weekStrArr = "周日/周一/周二/周三/周四/周五/周六".split("/");
    var weekArr = s.split(',');
    var weekStr = "";
    for(i=0;i<weekArr.length;i++){
        if(weekArr[i]){
            weekStr += weekStrArr[parseInt(weekArr[i])]+"/";
            if(!$('#s_time_box #sWeek'+weekArr[i]+'').is(':checked')){
                $('label[for="sWeek'+weekArr[i]+'"]').trigger("click");
            }
            $('#sWeek'+weekArr[i]).attr("checked","checked");
        }
    }
    return weekStr.substr(0,weekStr.length-1);
}

//$(function () {

    //输出星期
    $('#s_time_but a p.fs07').text(getWeekStr($('#s_time_but a p.fs07').attr('data')));

    //logo
    $("#uploaderInput0").change(function(){

        $('#loadingToast').show();
        window.setTimeout(function(){
            var formData = new FormData();
            formData.append("type","logo");
            formData.append("img",$("#uploaderInput0")[0].files[0]);
            $.ajax({
                url: '{:url("Base/get_upload_img")}' ,
                type: 'POST',
                data: formData,
                async: false,
                cache: true,
                contentType: false,
                processData: false,
                dataType:"json",
                error: function (d) {
                    $('#loadingToast').fadeOut();
                    alert('网络异常');
                },
                success: function (d) {
                    $('#loadingToast').fadeOut();
                    if(!d.code){
                        alert(d.msg);
                    }else{
                        $("#uploaderInput0_img").attr('src',SCOPE.image_host_url+d.data.path);
                        repair_info_change(["logo"],[d.data.path]);
                    }
                }
            });
        },666);

    });

    //点返回关闭面板
    $('.msg_panel .msui_navTop-back').click(function(){
        $(this).parents('.msg_panel').animate({"left":"100%"});
    });

    //点店铺名称
    $('#s_repair_name_but').click(function(){
        $('#s_repair_name_box').animate({"left":"0px"});
    });
    //点保存店铺名称
    $('#s_repair_name_box a.msui_navTop-icon').click(function(){
        var tmpVal = $('#s_repair_name_box input[name="repair_name"]').val();
        if(tmpVal.length<4 || tmpVal.length>20){
            alert('请输入4-20个字');return false;
        }
        $(this).parents('.msg_panel').animate({"left":"100%"});
        $("#s_repair_name_but a").text(tmpVal);
        repair_info_change(["repair_name"],[tmpVal]);
    });

    //点店铺地址
    $('#s_address_but').click(function(){
        $('#s_address_box').animate({"left":"0px"});
    });
    //点保存店铺地址
    $('#s_address_box a.store_cash_btn').click(function(){
        var tmpVal1 = $('#s_address_box input[name="s_province"]').val();
        var tmpVal2 = $('#s_address_box input[name="s_city"]').val();
        var tmpVal3 = $('#s_address_box input[name="s_area"]').val();
        var tmpVal4 = $('#s_address_box select[name="s_street"]').val();
        var tmpVal5 = $('#s_address_box input[name="s_address"]').val();
        var tmpVal6 = $('#s_address_box input[name="s_lat"]').val();
        var tmpVal7 = $('#s_address_box input[name="s_lon"]').val();
        if(!tmpVal4){
            alert('请选择街道');return false;
        }
        if( tmpVal5.length<3 ){
            alert('请填写详细地址');return false;
        }
        if( !parseFloat(tmpVal6) || !parseFloat(tmpVal7) ){
            alert('请选择您的地图坐标');return false;
        }
        $(this).parents('.msg_panel').animate({"left":"100%"});
        $("#s_address_box a").text(tmpVal5);
        repair_info_change(["province","city","area","street","address","lat","lon"],[tmpVal1,tmpVal2,tmpVal3,tmpVal4,tmpVal5,tmpVal6,tmpVal7]);
    });

    //营业时间
    $('#s_time_but').click(function(){
        $('#s_time_box').animate({"left":"0px"});
    });
    //点保存营业时间
    $('#s_time_box a.msui_navTop-icon').click(function(){
        var open_time = $('#s_time_box input[name="open_time"]').val();
        var close_time = $('#s_time_box input[name="close_time"]').val();
        var tmpWeek = "";
        tmpWeek += $('#s_time_box #sWeek0').is(':checked')?'0,':'';
        tmpWeek += $('#s_time_box #sWeek1').is(':checked')?'1,':'';
        tmpWeek += $('#s_time_box #sWeek2').is(':checked')?'2,':'';
        tmpWeek += $('#s_time_box #sWeek3').is(':checked')?'3,':'';
        tmpWeek += $('#s_time_box #sWeek4').is(':checked')?'4,':'';
        tmpWeek += $('#s_time_box #sWeek5').is(':checked')?'5,':'';
        tmpWeek += $('#s_time_box #sWeek6').is(':checked')?'6,':'';
        if(!open_time){
            alert('请选择营业开始时间');return false;
        }
        if(!close_time){
            alert('请选择营业结束时间');return false;
        }
        if(!tmpWeek){
            alert('请选择营业日');return false;
        }
        $('#s_time_box').animate({"left":"100%"});
        repair_info_change(["open_time","close_time","week"],[open_time,close_time,tmpWeek]);
        $('#s_time_but a p.fs07').text(getWeekStr(tmpWeek));
        $('#s_time_but a p.fs05').text(open_time+':00-'+close_time+':00');


    });

    //点经营项目
    $('#s_item_but').click(function(){
        $('#s_item_box').animate({"left":"0px"});
    });
    //点保存经营项目
    $('#s_item_box a.msui_navTop-icon').click(function(){

        var add_id = '';
        var del_id = '';
        $('#s_item_box input[type="checkbox"]').each(function(){
            if( $(this).is(':checked') ){
                if( !$(this).attr("data_r_id") ){
                    add_id += $(this).attr("data_id")+",";
                    $(this).attr("data_r_id","1");
                }
                $("#myItem"+$(this).attr("data_id")).show();
            }else{
                if( $(this).attr("data_r_id") ){
                    del_id += $(this).attr("data_id")+",";
                    $(this).attr("data_r_id","");
                }
                $("#myItem"+$(this).attr("data_id")).hide();
            }
        });
        add_id = add_id?add_id.substr(0,add_id.length-1):'';
        del_id = del_id?del_id.substr(0,del_id.length-1):'';

        if(add_id=="" && del_id==""){
            alert('您没有做出选择或修改');return false;
        }

        $('#loadingToast').fadeIn();
        $.ajax({
            url: '{:url("repair_item_change")}' ,
            type: 'POST',
            data: {
                add_id : add_id,
                del_id : del_id
            },
            dataType:"json",
            error: function (d) {
                $('#loadingToast').fadeOut();
                alert('网络异常');
            },
            success: function (d) {
                $('#loadingToast').fadeOut();
                if(!d.code){
                    alert(d.msg);
                }else{
                    $('#s_item_box').animate({"left":"100%"});
                }
            }
        });


    });

    //点保证金
    $('#s_ketubbah_but').click(function(){
        $('#s_ketubbah_box').animate({"left":"0px"});
    });
    //点缴纳开通保证金
    $('#s_ketubbah_box #s_ketubbah_pay_but').click(function(){
        var nowMoney = parseFloat($(this).attr("nowMoney"));
        var payMoney = parseFloat($(this).attr("payMoney"));
        if(nowMoney>=payMoney){
            $.confirm("从余额中支付"+payMoney+"元缴纳开通<br>是否确定?","确认缴纳开通",function(){
                $('#loadingToast').fadeIn();
                $.ajax({
                    type:"get",
                    cache:false,
                    dataType:"json",
                    url:'{:url("repair_ketubbah_pay")}',
                    error:function(s){
                        $('#loadingToast').fadeOut();
                        alert('网络异常');
                    },
                    success:function(d){
                        $('#loadingToast').fadeOut();
                        if(d.code!=200){
                            alert(d.msg);
                        }else{
                            window.location.reload();
                        }
                    }
                });
            },function(){
                return false;
            });
        }else{
            $.confirm("您的余额不足"+payMoney+"元<br>是否前往充值?","余额不足,确认充值",function(){
                window.location.href = '{:url("pay/order_pay")}?m='+payMoney+'&model=order_recharge&type=1';
            },function(){
                return false;
            });
        }
    });
    //点退保证金
    $('#s_ketubbah_box #s_ketubbah_refund_but').click(function(){
            $.confirm("保障金将退回到余额中<br>是否确定?","确认退保障金",function(){
                $('#loadingToast').fadeIn();
                $.ajax({
                    type:"get",
                    cache:false,
                    dataType:"json",
                    url:'{:url("repair_ketubbah_refund")}',
                    error:function(s){
                        $('#loadingToast').fadeOut();
                        alert('网络异常');
                    },
                    success:function(d){
                        $('#loadingToast').fadeOut();
                        if(d.code!=200){
                            alert(d.msg);
                        }else{
                            window.location.reload();
                        }
                    }
                });
            },function(){
                return false;
            });

    });

    //点营业执照
    $('#s_business_license_but').click(function(){
        $('#s_business_license_box').animate({"left":"0px"});
    });
    //点提交审核营业执照
    $('#s_business_license_box a.weui-btn').click(function(){
        var business_license_name = $("#s_business_license_box input[name='business_license_name']").val();
        var business_license_num = $("#s_business_license_box input[name='business_license_num']").val();
        var business_license = $("#s_business_license_box input[name='business_license']").val();
        if(business_license_name.length<5){alert('请填写营业执照名称');return false;}
        if(business_license_num.length<9){alert('请填写营业执照号码');return false;}
        if(business_license.length<15){alert('请上传营业执照图片');return false;}
        repair_info_change(["business_license_name","business_license_num","business_license","is_certification"],[business_license_name,business_license_num,business_license,1]);
        $("#s_business_license_but a.store_message_yy img").attr("src",business_license);
        $('#s_business_license_box').animate({"left":"100%"});
    });
    //点营业执照图片
    $("#uploaderInput1").change(function(){
        $('#loadingToast').show();
        window.setTimeout(function(){
            var formData = new FormData();
            formData.append("type","logo");
            formData.append("img",$("#uploaderInput1")[0].files[0]);
            $.ajax({
                url: '{:url("Base/get_upload_img")}' ,
                type: 'POST',
                data: formData,
                async: false,
                cache: true,
                contentType: false,
                processData: false,
                dataType:"json",
                error: function (d) {
                    $('#loadingToast').fadeOut();
                    alert('网络异常');
                },
                success: function (d) {
                    $('#loadingToast').fadeOut();
                    if(!d.code){
                        alert(d.msg);
                    }else{
                        $("#s_business_license_box a.store_message_yy img").attr("src",SCOPE.image_host_url+d.data.path);
                        $("#s_business_license_box input[name='business_license']").val(d.data.path);
                    }
                }
            });
        },666);

    });

    //点店铺门面
    $('#s_cover_but').click(function(){
        $('#s_cover_box').animate({"left":"0px"});
    });
    //点上传照片提交店铺门面图片
    $("#uploaderInput2").change(function(){
        $('#loadingToast').show();
        window.setTimeout(function(){
            var formData = new FormData();
            formData.append("type","logo");
            formData.append("img",$("#uploaderInput2")[0].files[0]);
            $.ajax({
                url: '{:url("Base/get_upload_img")}' ,
                type: 'POST',
                data: formData,
                async: false,
                cache: true,
                contentType: false,
                processData: false,
                dataType:"json",
                error: function (d) {
                    $('#loadingToast').fadeOut();
                    alert('网络异常');
                },
                success: function (d) {
                    $('#loadingToast').fadeOut();
                    if(!d.code){
                        alert(d.msg);
                    }else{
                        $("#s_cover_box .shop_store_img1 img").attr("src",SCOPE.image_host_url+d.data.path);
                        $("#s_cover_box input[name='cover']").val(d.data.path);
                        repair_info_change(["cover"],[d.data.path]);
                        $('#s_cover_box').animate({"left":"100%"});
                    }
                }
            });
        },666);

    });

    //点环境图
    $('#s_environment_img_but').click(function(){
        $('#s_environment_img_box').animate({"left":"0px"});
    });
    //点环境图提交照片
    $('#s_environment_img_box a.weui-btn').click(function(){
        var　arr1 = new Array();
        arr1[0] = arr1[1] = arr1[2] = arr1[3] = arr1[4] = arr1[5] = arr1[6] = arr1[7] = "";
        for(i=0;i<$("img.weui-flex__item.new_add").length;i++){
            arr1[i] = '/uploads/'+$("img.weui-flex__item")[i].src.split('/uploads/')[1];
        }
        repair_info_change(["environment_img1","environment_img2","environment_img3","environment_img4","environment_img5","environment_img6","environment_img7","environment_img8"],arr1);
        $('#s_environment_img_box').animate({"left":"100%"});
    });

    //填充省市区
    var num1 = parseInt($('input[name="s_province"]').val());
    var num2 = parseInt($('input[name="s_city"]').val());
    var num3 = parseInt($('input[name="s_area"]').val());
    if( num1 && num2 && num3 ){
        for(i=0;i<$.mob_data_picker1.length;i++){
            if($.mob_data_picker1[i].code==num1){
                var num1 = i;
                var str1 = $.mob_data_picker1[i].name;
            }
        }
        for(i=0;i<$.mob_data_picker1[num1].sub.length;i++){
            if($.mob_data_picker1[num1].sub[i].code==num2){
                var num2 = i;
                var str2 = $.mob_data_picker1[num1].sub[i].name;
            }
        }
        for(i=0;i<$.mob_data_picker1[num1].sub[num2].sub.length;i++){
            if($.mob_data_picker1[num1].sub[num2].sub[i].code==num3){
                var num3 = i;
                var str3 = $.mob_data_picker1[num1].sub[num2].sub[i].name;
            }
        }
        $("input[name='s_shengshiqu']").val(str1+' '+str2+' '+str3);
    }
    $("input[name='s_shengshiqu']").cityPicker({
        title: "选择省市区",
        onChange: function (picker, values, displayValues) {
            return false;
        },
        onClose: function(r1){

            $("input[name='s_province']").val(r1.value[0]);
            $("input[name='s_city']").val(r1.value[1]);
            $("input[name='s_area']").val(r1.value[2]);

            $('#loadingToast').fadeIn();
            $.ajax({
                type:"get",
                cache:false,
                dataType:"json",
                url:"/wechat/base/get_street.html?area="+r1.value[2]+"",
                error:function(s){
                    $('#loadingToast').fadeOut();
                    alert('网络异常');
                },
                success:function(d){
                    $('#loadingToast').fadeOut();
                    if(d.code!=200){
                        alert(d.msg);
                    }else{

                        var defaultData = $('select[name="s_street"]').attr("data");
                        var html = [];
                        var data = d.data;
                        var len = data.length;
                        html.push('<option>请选择...</option>');
                        for (var i = 0; i < len; i++) {
                            if(defaultData==data[i].region_id){
                                html.push("<option value='"+ data[i].region_id +"' selected='selected'>"+ data[i].region_name +"</option>");
                            }else{
                                html.push("<option value='"+ data[i].region_id +"'>"+ data[i].region_name +"</option>");
                            }
                        }
                        $("select[name='s_street']").html(html.join(''));
                    }
                }
            });
        }
    });
    //获取一下省市区对应的data-codes
    if($("input[name='s_shengshiqu']").val()) {
        $("input[name='s_shengshiqu']").data().picker.open();
        $("input[name='s_shengshiqu']").data().picker.close();
    }



    //初始化地图
    mapObj = new AMap.Map('container',{
        resizeEnable: true,
        zoom: 15
        //zoomEnable: false,	//禁止放大缩小
        //dragEnable: false,	//禁止拖动
    });



    //地图选择定位经纬度
    $('#box_map_open').click(function(){
        $('#box_map').css("display","block");
        $('#box_map').css("height",$(window).height());
    });
    $('#box_map_close').click(function(){
        $('#box_map').css("display","none");
    });


    if( !$('input[name="s_address"]').val() ){
        //监控用户位置
        mapObj.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true,//是否使用高精度定位，默认:true
                timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                maximumAge: 666666,           //定位结果缓存0毫秒，默认：0
                convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                showButton: true,        //显示定位按钮，默认：true
                buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                buttonOffset: new AMap.Pixel(10, 10),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                showCircle: false,        //定位成功后用圆圈表示定位精度范围，默认：true
                panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                extensions: 'base'
            });
            //markerOptions: window.my_dingdan,
            mapObj.addControl(geolocation);//开始监控
            AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息//onComplete
            AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
            $(".amap-geo").trigger("click");
        });
    }else{
        if($('input[name="s_lat"]').val()!="0" && $('input[name="s_lon"]').val()!="0"){
            mapObj.setCenter(new AMap.LngLat($('input[name="s_lon"]').val(),$('input[name="s_lat"]').val()))
        }
    }


    //开始拖拽地图时
    mapObj.on("dragstart", function(){
        window.clearTimeout(window.dragTime);
    });
    //拖拽地图过程中
    mapObj.on("dragging", function(){
        //window.clearTimeout(window.dragTime);

    });
    //停止拖拽地图时
    mapObj.on("dragend", function(){
        window.dragTime = setTimeout(function() {
            var tmp = mapObj.getCenter();console.log(tmp);
            $('input[name="s_lat"]').val(tmp.lat);
            $('input[name="s_lon"]').val(tmp.lng);
            map_get_address();
        },666);
    });







//});



</script>
{/block}